package com.example.demo.controller;

import com.example.demo.entity.Result;
import com.example.demo.service.impl.ProjectServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import java.util.UUID;

@RestController
@RequestMapping("sys/project")
public class ProjectController {
    @Autowired
    private ProjectServiceImpl projectService;

    @GetMapping("getAllCust")
    public Result getAllFinance(@RequestParam Map<String,Object> params, HttpServletRequest request){
        return projectService.getAllCust(params);
    }

    @GetMapping("getAllCust1")
    public Result getAllCust1(@RequestParam Map<String,Object> params, HttpServletRequest request){
        return projectService.getAllCust1(params);
    }
    @PostMapping("insertCust")
    public Result insertCust(@RequestBody Map<String,Object> params, HttpServletRequest request){
        params.put("custId", UUID.randomUUID().toString().substring(0,7));
        return projectService.insertCust(params);
    }

    @PostMapping("updateCust")
    public Result updateCust(@RequestBody Map<String,Object> params, HttpServletRequest request){
        return projectService.updateCust(params);
    }

    @GetMapping("getProject")
    public Result getProject(@RequestParam Map<String,Object> params, HttpServletRequest request){
        return projectService.getProject(params);
    }
    @GetMapping("getProject1")
    public Result getProject1(@RequestParam Map<String,Object> params, HttpServletRequest request){
        return projectService.getProject1(params);
    }

    @PostMapping("insertProject")
    public Result insertProject(@RequestBody Map<String,Object> params, HttpServletRequest request){
        params.put("pkId", UUID.randomUUID().toString().substring(0,7));
        return projectService.insertProject(params);
    }

    @PostMapping("updateProject")
    public Result updateProject(@RequestBody Map<String,Object> params, HttpServletRequest request){
        return projectService.updateProject(params);
    }

    @PostMapping("insertProjectFollow")
    public Result insertProjectFollow(@RequestBody Map<String,Object> params, HttpServletRequest request){
        return projectService.insertProjectFollow(params);
    }

    @GetMapping("getProjectFollow")
    public Result getProjectFollow(@RequestParam Map<String,Object> params, HttpServletRequest request){
        return projectService.getProjectFollow(params);
    }

    @GetMapping("getSalePlan")
    public Result getSalePlan(@RequestParam Map<String,Object> params, HttpServletRequest request){
        return projectService.getSalePlan(params);
    }

    @PostMapping("insertSalePlan")
    public Result insertSalePlan(@RequestBody Map<String,Object> params, HttpServletRequest request){
        params.put("pkId", UUID.randomUUID().toString().substring(0,7));
        return projectService.insertSalePlan(params);
    }

}
